package com.ruoyi.system.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.system.domain.BsMenpiaoCategory;
import com.ruoyi.system.domain.BsMenpiaoNum;
import com.ruoyi.system.service.BsMenpiaoCategoryService;
import com.ruoyi.system.service.BsMenpiaoNumService;
import com.ruoyi.system.mapper.BsMenpiaoNumMapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 *
 */
@Service
public class BsMenpiaoNumServiceImpl extends ServiceImpl<BsMenpiaoNumMapper, BsMenpiaoNum>
    implements BsMenpiaoNumService{

    @Resource
    private BsMenpiaoCategoryService bsMenpiaoCategoryService;

    @Override
    public boolean removeByJingquId(Long jingquId) {
        LambdaQueryWrapper<BsMenpiaoNum> lqw = new LambdaQueryWrapper<>();
        lqw.eq(BsMenpiaoNum::getJingquId,jingquId);
        return remove(lqw);
    }

    @Override
    public List<BsMenpiaoNum> listByJingquId(Long jingquId) {
        LambdaQueryWrapper<BsMenpiaoNum> lqw = new LambdaQueryWrapper<>();
        lqw.eq(BsMenpiaoNum::getJingquId,jingquId);
        return list(lqw);
    }

    @Override
    public BsMenpiaoCategory getCategoryByNumId(Long menpiaoNumId) {
        BsMenpiaoNum menpiaoNum = getById(menpiaoNumId);
        return bsMenpiaoCategoryService.getById(menpiaoNum.getMenpiaoCategoryId());
    }
}




